package com.ruoyi.stock2.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.stock2.domain.SelectModelFromPca;
import com.ruoyi.stock2.service.ISelectModelFromPcaService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 从PCA挑选的接近的模型Controller
 * 
 * @author ruoyi
 * @date 2020-03-17
 */
@Controller
@RequestMapping("/stock2/SelectModelFromPca")
public class SelectModelFromPcaController extends BaseController
{
    private String prefix = "stock2/SelectModelFromPca";

    @Autowired
    private ISelectModelFromPcaService selectModelFromPcaService;

    @RequiresPermissions("stock2:SelectModelFromPca:view")
    @GetMapping()
    public String SelectModelFromPca()
    {
        return prefix + "/SelectModelFromPca";
    }

    /**
     * 查询从PCA挑选的接近的模型列表
     */
    @RequiresPermissions("stock2:SelectModelFromPca:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(SelectModelFromPca selectModelFromPca)
    {
        startPage();
        List<SelectModelFromPca> list = selectModelFromPcaService.selectSelectModelFromPcaList(selectModelFromPca);
        return getDataTable(list);
    }

    /**
     * 导出从PCA挑选的接近的模型列表
     */
    @RequiresPermissions("stock2:SelectModelFromPca:export")
    @Log(title = "从PCA挑选的接近的模型", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(SelectModelFromPca selectModelFromPca)
    {
        List<SelectModelFromPca> list = selectModelFromPcaService.selectSelectModelFromPcaList(selectModelFromPca);
        ExcelUtil<SelectModelFromPca> util = new ExcelUtil<SelectModelFromPca>(SelectModelFromPca.class);
        return util.exportExcel(list, "SelectModelFromPca");
    }

    /**
     * 新增从PCA挑选的接近的模型
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存从PCA挑选的接近的模型
     */
    @RequiresPermissions("stock2:SelectModelFromPca:add")
    @Log(title = "从PCA挑选的接近的模型", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(SelectModelFromPca selectModelFromPca)
    {
        return toAjax(selectModelFromPcaService.insertSelectModelFromPca(selectModelFromPca));
    }

    /**
     * 修改从PCA挑选的接近的模型
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        SelectModelFromPca selectModelFromPca = selectModelFromPcaService.selectSelectModelFromPcaById(id);
        mmap.put("selectModelFromPca", selectModelFromPca);
        return prefix + "/edit";
    }

    /**
     * 修改保存从PCA挑选的接近的模型
     */
    @RequiresPermissions("stock2:SelectModelFromPca:edit")
    @Log(title = "从PCA挑选的接近的模型", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(SelectModelFromPca selectModelFromPca)
    {
        return toAjax(selectModelFromPcaService.updateSelectModelFromPca(selectModelFromPca));
    }

    /**
     * 删除从PCA挑选的接近的模型
     */
    @RequiresPermissions("stock2:SelectModelFromPca:remove")
    @Log(title = "从PCA挑选的接近的模型", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(selectModelFromPcaService.deleteSelectModelFromPcaByIds(ids));
    }
}
